﻿using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace Vidh.SimplyToDo.Controllers.ViewModels
{
    public class LoginModel : BaseModel
    {
        public LoginModel()
        {
        }

        public int ID { get; set; }

        [Required]
        [DataType(DataType.EmailAddress)]
        public string Email { get; set; }

        [Required]
        [DataType(DataType.Password)]
        public string Password { get; set; }

        public string FirstName { get; set; }
        public string LastName { get; set; }

        public bool Authenticate(ModelStateDictionary modelState)
        {
            if (modelState.IsValid)
            {
                return true;
            }

            modelState.AddModelError("", " Invalid Credentials!");
            return false;
        }

        public void Logout()
        {
            _formsAuthHelper.SignOut();
        }
    }
}
